package cn.nfwx.tv.callback;

import com.google.gson.Gson;
import com.tencent.mm.opensdk.utils.Log;

import org.json.JSONObject;

import cn.nfwx.tv.model.UserModel;
import cn.nfwx.tv.util.LogUtil;

/**
 * Created by dell on 2017/11/14.
 */

public  abstract class UserCallBack implements  ResponseWithFailListener<JSONObject> {
    private final static String TAG_LOG = UserCallBack.class.getSimpleName();

    public abstract void onSuccess(UserModel userModel);

    @Override
    public void onResponse(String tag,JSONObject response) {
            LogUtil.d(TAG_LOG,"response:"+response.toString());
            Gson gson=new Gson();
            UserModel user=gson.fromJson(response.toString(),UserModel.class);
            onSuccess(user);
            onComplete();
    }

    @Override
    public void onError(String tag,Throwable t) {
        Log.d("onError",t.getMessage()+"");
        onFail(tag,t.getMessage());
        onComplete();
    }

    @Override
    public void onFinish() {

    }

    public void onComplete() {
    }
}
